package com.atguigu.auth.activiti;

import org.activiti.engine.HistoryService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * ClassName: ProcessTest2
 * Package: com.atguigu.auth.activiti
 * Description:
 *
 * @Author 蹇泽阳
 * @Create 2023/11/20 22:29
 * @Version 1.0
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class ProcessTest4 {
  @Autowired
  private HistoryService historyService;
  
  @Autowired
  private TaskService taskService;
  
  @Autowired
  private RuntimeService runtimeService;
  
  @Autowired
  private RepositoryService repositoryService;
  
 
  
  @Test
  public void deployProcess04() {
    // 流程部署
    Deployment deploy = repositoryService.createDeployment()
        .addClasspathResource("process/jiaban3.bpmn20.xml")
        .name("加班申请流程")
        .deploy();
    System.out.println(deploy.getId());
    System.out.println(deploy.getName());
  }
  
  /**
   * 启动流程实例
   */
  @Test
  public void startUpProcess03() {
    //创建流程实例,我们需要知道流程定义的key
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("jiaban3");
    //输出实例的相关信息
    System.out.println("流程定义id：" + processInstance.getProcessDefinitionId());
    System.out.println("流程实例id：" + processInstance.getId());
  }
}
